package org.study.mybatisplus.dynamic.boot.config;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2024年10月21日
 */
public interface TypeEnum {
    interface StatisticsType {
        String STATISTICS_TYPE_YEAR = "year";
        String STATISTICS_TYPE_MONTH = "month";
        String STATISTICS_TYPE_DAY = "day";
    }

    @Getter
    @AllArgsConstructor
    enum DeviceTypeEnum {
        XIANG_BIAN("d_xb", "箱变"),
        SHU_CAI("d_sc", "数采"),
        NI_BIAN_QI("d_nbq", "逆变器"),
        NI_BIAN_QI_MPPT("d_nbq_mppt", "MPPT"),
        NI_BIAN_QI_MPPT_PV("d_nbq_mppt_pv", "组串"),
        DIAN_BIAO("d_db", "电表"),
        DIAN_BIAO_CLD("d_db_cld", "电表测量点"),
        ;

        private String type;
        private String desc;

        public static List<Map<String, String>> getAllDeviceType() {
            List<Map<String, String>> list = new ArrayList<>();
            for (DeviceTypeEnum deviceTypeEnum : DeviceTypeEnum.values()) {
                Map<String, String> map = new HashMap<>();
                map.put(deviceTypeEnum.getType(), deviceTypeEnum.getDesc());
                list.add(map);
            }
            return list;
        }

        public static boolean isDeviceTypeExist(String type) {
            for (DeviceTypeEnum deviceTypeEnum : DeviceTypeEnum.values()) {
                if (deviceTypeEnum.getType().equals(type)) {
                    return true;
                }
            }
            return false;
        }
    }

    @Getter
    @AllArgsConstructor
    enum DevicePropertyTypeEnum {
        // 箱变相关
        // XB_("dp_xb_1001", ""),
        // 数采相关
        SC_FDL_DR("dp_sc_fdl_dr", "数采当日发电量"),
        SC_FDL_DZ("dp_sc_fdl_dz", "数采当周发电量"),
        SC_FDL_DY("dp_sc_fdl_dy", "数采当月发电量"),
        SC_FDL_DN("dp_sc_fdl_dn", "数采当年发电量"),
        SC_FDL_LJ("dp_sc_fdl_lj", "数采累计发电量"),
        SC_GL_YG("dp_sc_gl_yg", "数采有功功率"),
        SC_GL_WG("dp_sc_gl_wg", "数采无功功率"),
        // 逆变器相关
        NBQ_FDL_DR("dp_nbq_fdl_dr", "逆变器当天发电量"),
        NBQ_FDL_DY("dp_nbq_fdl_dy", "逆变器当月发电量"),
        NBQ_FDL_DN("dp_nbq_fdl_dn", "逆变器当年发电量"),
        NBQ_FDL_LJ("dp_nbq_fdl_lj", "逆变器总发电量"),
        NBQ_GL_YG("dp_nbq_gl_yg", "逆变器有功功率"),
        NBQ_GL_WG("dp_nbq_gl_wg", "逆变器无功功率"),
        NBQ_PV_DY("dp_nbq_pv_dy", "逆变器PV输入电压"),
        NBQ_PV_DL("dp_nbq_pv_dl", "逆变器PV输入电流"),
        // 电表相关
        DB_ZXYGZ("dp_db_zxygz", "电表正向有功总"),
        DB_FXYGZ("dp_db_fxygz", "电表反向有功总"),
        DB_ZXWGZ("dp_db_zxwgz", "电表正向无功总"),
        DB_FXWGZ("dp_db_fxwgz", "电表反向无功总"),
        ;

        private String type;
        private String desc;

        public static List<Map<String, String>> getAllDevicePropertyType() {
            List<Map<String, String>> list = new ArrayList<>();
            for (DevicePropertyTypeEnum devicePropertyTypeEnum : DevicePropertyTypeEnum.values()) {
                Map<String, String> map = new HashMap<>();
                map.put(devicePropertyTypeEnum.getType(), devicePropertyTypeEnum.getDesc());
                list.add(map);
            }
            return list;
        }

        public static boolean isDevicePropertyTypeExist(String type) {
            for (DevicePropertyTypeEnum devicePropertyTypeEnum : DevicePropertyTypeEnum.values()) {
                if (devicePropertyTypeEnum.getType().equals(type)) {
                    return true;
                }
            }
            return false;
        }
    }
}
